import React from "react";
import "@/views/index/index.css";
import "@/assets/css/style.css";
import {Avatar, Layout} from 'antd';
import { connect  } from 'react-redux';
import { maploginout } from '@/store/connect'

const { Header} = Layout;

class MyHeader extends React.Component{
    constructor(props){
        super(props)
        this.state = {
            isAuthenticated: true
        };
    }

    loginout = (e) => {
        this.props.onLogout();
        sessionStorage.removeItem('isAuthenticated');
        this.setState({
            isAuthenticated: true
        })
    }

    render() {
        return (
            <div>
                <Header className="header clearfix">
                    <h3>企业进销存后台管理系统</h3>
                    <div className="control_panel">
                        <a href="#" className="user_set">
                            <Avatar icon="user"/>
                            <span onClick={this.loginout}>admin</span>
                        </a>
                    </div>
                </Header>
            </div>
        );
    }

}

export default connect(maploginout.mapStateToProps, maploginout.mapDispatchToProps)(MyHeader);
